<template>
  <div>
    <h1>Promise对象（promise 回调用,保证异步请求按顺序执行）</h1><hr>
    <el-button @click="start">start</el-button>
  </div>
</template>

<script>
export default {
  data() {
    return {

    }
  },
  methods: {
    start() {
      return new Promise((resolve, reject) => {
        setTimeout(() => {
          resolve('hello')
          // reject('hello')
        }, 2000)
      }).then(res => {
        console.log(res)
        return new Promise(resolve => {
          setTimeout(() => {
            resolve('world')
          }, 2000)
        })
      }).then(val => {
        console.log(val) // 参数val = 'world'
      }).catch(error => {
        console.log('发生错误！', error)
      })
    }

  }
}
</script>

  <style>

  </style>
